#!/bin/sh

cp /lib64/ld-linux-aarch64.so.1 /lib/

#Before loading the wifi driver, the relevant pins must be set first
#UART5
bspmm 0x102F0100 0x1204
bspmm 0x102F0104 0x1204
bspmm 0x102F0108 0x1204
bspmm 0x102F010C 0x1204
#SDIO1
bspmm 0x102F0054 0x1101
bspmm 0x102F0050 0x1101
bspmm 0x102F0040 0x1101
bspmm 0x102F0044 0x1101
bspmm 0x102F0048 0x1101
bspmm 0x102F004C 0x1101
#GPIO
bspmm 0x10230048 0x1200
bspmm 0x10230044 0x1200
bspmm 0x10230040 0x1200
bspmm 0x1023003C 0x1200
bspmm 0x102F00F4 0x1201

cd /ko

bash ./load_ss928v100 -i -total 8192 -osmem 4096


echo 47 > /sys/class/gpio/export 
echo out >/sys/class/gpio/gpio47/direction 
echo 1 > /sys/class/gpio/gpio47/value

#echo 72 > /sys/class/gpio/export
#echo out >/sys/class/gpio/gpio72/direction
#echo 0 > /sys/class/gpio/gpio72/value


bspmm 0x0102F00F0  0x1201  #GPIO9_5
bspmm 0x0102F0110  0x1201  #GPIO10_5


#SDIO LEVEL TO 3.3v
bspmm 0x102e0010 0x11


#GPIO7_1 GPIO7_2 GPIO6_6
bspmm 0x0102F0094 0x1201
bspmm 0x0102F0098 0x1201
bspmm 0x0102F0088 0x1201
bspmm 0x0102F0084 0x1201
bspmm 0x0102F0080 0x1201

echo 57 > /sys/class/gpio/export 
echo out >/sys/class/gpio/gpio57/direction 
echo 1 > /sys/class/gpio/gpio57/value

echo 58 > /sys/class/gpio/export 
echo out >/sys/class/gpio/gpio58/direction 
echo 1 > /sys/class/gpio/gpio58/value

echo 54 > /sys/class/gpio/export 
echo out >/sys/class/gpio/gpio54/direction 
echo 1 > /sys/class/gpio/gpio54/value

#GPIO6_2  1-> 928 HDMIout   0->loop hdmiout
echo 50 > /sys/class/gpio/export 
echo out >/sys/class/gpio/gpio50/direction 
echo 1 > /sys/class/gpio/gpio50/value

#UART2 MUX
bspmm 0x0102F0070 0x1201
bspmm 0x0102F0074 0x1201
bspmm 0x0102F0078 0x1200  #RS232
bspmm 0x0102F007C 0x1200  #RS232

#UART1 MUX
bspmm 0x0102F0060 0x1201
bspmm 0x0102F0064 0x1201
bspmm 0x0102F006C 0x1200  #RS232
bspmm 0x0102F0068 0x1200  #RS232

#UART3 MUX
bspmm 0x0102f012c 0x00001201
bspmm 0x0102f0130 0x00001201
bspmm 0x0102f00D0 0x00001200   #RS485

#UART4 MUX
bspmm 0x0102f0134 0x00001201
bspmm 0x0102f0138 0x00001201

#RTC 生成1秒脉冲
i2c_write 0 0x64 0xd 0x44

#mipi GPIO config 
bspmm 0x102f0150 0x1100
bspmm 0x102f0160 0x1100

echo 97 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio97/direction
echo 1 > /sys/class/gpio/gpio97/value

echo 101 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio101/direction
echo 1 > /sys/class/gpio/gpio101/value

#wait for chip to start and complete 
sleep 1
res=`i2c_read 4 0xd0 0xa9 0xa9 1 1 |grep error`
if [ -z "$res" ]; then
    echo "start config rohm"
    bash /etc/init.d/rohm_400M.sh > /dev/null
    echo "config rohm success"
fi

echo 46 > /sys/class/gpio/export 
echo out >/sys/class/gpio/gpio46/direction 
echo 0 > /sys/class/gpio/gpio46/value
echo 'nameserver 8.8.8.8' >> /etc/resolv.conf
# ifconfig eth0 192.168.0.22 netmask 255.255.255.0
# route -n add default gw 192.168.0.1
